const request=require('../../../utils/request.js');
const globleurl = require('../../../utils/serverconfig.js').url;
Page({

  data: {

  },

  onLoad: function (options) {

    let userid=parseInt(options.userid);
   
    this.setData({
      userid
    });
    this.getmyorder();
  },


  async getmyorder(e){
    let orderdata=await  request.myrequest('/miniapp/showmyorder',{userid:this.data.userid});
   
    orderdata.data.forEach(item=>{
      item.img_url=globleurl+item.img_url;
    });
    this.setData({
      orderdata:orderdata.data
    })
  },


  showdetail(e){

    let orderdata=this.data.orderdata[e.currentTarget.dataset.index];
    if(orderdata){
      orderdata=JSON.stringify(orderdata);
      wx.navigateTo({
        url: `./orderdetail/orderdetail?orderdata=${orderdata}`
      })
    }
  }
  
})